using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Deepcode.Flux.Core.Data;

namespace Deepcode.Flux.Core.Systems.Workflow.Bases
{
	/// <summary>
	/// Represents a workflow definition in WFDefinitions
	/// </summary>
	public class Definition
	{
		// Private fields for storing record fields //
		private int				_PK_ID = -1;
		private string			_HandlerCodeID = "";
		private string			_DefName = "";

		// Public fields exposing record fields //
		public int PK_ID { get { return _PK_ID; } set { _PK_ID = value; } }
		public string HandlerCodeID { get{ return _HandlerCodeID; } set{ _HandlerCodeID = value; }}
		public string DefName { get{ return _DefName; } set{ _DefName = value; }}

		// Linkbacks
		public Handler ParentHandler
		{
			get
			{
				Handlers handlers = new Handlers();
				return handlers.GetHandlerByID(HandlerCodeID);
			}
		}

		// Constructor to create new without loading
		public Definition() { }

		// Constructor loading from a data row
		public Definition(DataRow InitFromRow)
		{
			_PK_ID = SQLUtility.DBNull(InitFromRow["PK_ID"], -1);
			_HandlerCodeID = SQLUtility.DBNull(InitFromRow["HandlerCodeID"], "");
			_DefName = SQLUtility.DBNull(InitFromRow["DefName"], "");
		}
	}
}
